package com.controller;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.model.auto.ExpertCourseInfo;
import com.service.IExpertCourseInfoService;
import com.util.Page;
import com.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 专家课程信息 前端控制器
 * </p>
 *
 * @author astupidcoder
 * @since 2022-09-14
 */
@RestController
@RequestMapping("/expertCourseInfo")
public class ExpertCourseInfoController{
    @Autowired
    private IExpertCourseInfoService expertCourseInfoService;

    @GetMapping("/getExpertCourse")
    public R getExpertCourse(Page page, Integer expertId) {
        PageInfo<Object> pageInfo = PageHelper.startPage(page.getPageNum(), page.getPageSize())
                .doSelectPageInfo(() -> {
                    List<ExpertCourseInfo> list = expertCourseInfoService.list(
                            new LambdaQueryWrapper<ExpertCourseInfo>().
                                    eq(expertId != null, ExpertCourseInfo::getExpertId, expertId)
                                    .orderByAsc(ExpertCourseInfo::getSortNum)

                    );
                });
        return R.ok(pageInfo);
    }
}
